//
// Created by 14590 on 25-9-2.
//
#include "cmsis_os2.h"
#include "system.h"
#include "homepage.h"
#include "menu.h"
#include "syscfg.h"
#include "paraset.h"
#include "calimode.h"
#include "compmode.h"

extern osSemaphoreId_t PageSwSemBinaryHandle;

void (*DispFun)() = DispHomePage;
void (*KeyFun)() = KeyHomePage;
void LCD_Task(void *argument) {
    HAL_Delay(1000);
    SPI_LCD_Init();

    LCD_Setting();
    for (;;)
    {
        osStatus_t ret = osSemaphoreAcquire(PageSwSemBinaryHandle, 10);//获取信号量
        if (ret == osOK)//osOK：操作成功完成
        {
            LCD_Clear();
            switch (PageType) {
                case homepage: {
                    DispFun = DispHomePage;
                    KeyFun = KeyHomePage;
                    break;
                }
                case menu: {
                    DispFun = DispMenu;
                    KeyFun = KeyMenu;
                    break;
                }
                case calimode: {
                    DispFun = DispCaliMode;
                    KeyFun = KeyCaliMode;
                    break;
                }
                case compmode: {
                    DispFun = DispCompMode;
                    KeyFun = KeyCompMode;
                    break;
                }
                case syscfg: {
                    DispFun = DispSysCfg;
                    KeyFun = KeySysCfg;
                    break;
                }
                case paraset: {
                    DispFun = DispParaSet;
                    KeyFun = KeyParaSet;
                    break;
                }
            }
        }
        DispFun();
        KeyFun();
    }
}